<template>
    <div id="under-net-order" class="order-content">
        <el-row class="row-height top-row">
            <el-col :span="8" class="col-box" style="border-right: 1px solid #c9c9c9; height: 100%">
                <el-form label-width="110px" size="small" style="display: block; height: 100%; width: 100%">
                    <h3 class="title">
                        质押券试算信息:<i style="float: right; font-size: 25px" class="el-icon-setting" @click="openTransDialog"></i>
                    </h3>
                    <div style="height: calc(100% - 65px)">
                        <el-row class="form-row">
                            <el-col>
                                <el-form-item label="产品代码:">
                                    <RiskEntryInputs
                                        :showAll="false"
                                        :interfaceUrl="'/fundInfo/list/byUser/like?fundCodeOrName='"
                                        @set-entry-data="getAccountDebarValue"
                                        :showDis="false"
                                    />
                                    <!-- <el-select v-model="riskOrderForm.fundCodes" filterable collapse-tags multiple size="mini">
                                        <el-option
                                            v-for="i in fundCodeSelectData"
                                            :key="i.fundCode"
                                            :label="i.fundCode + ' ' + i.fundNameSt"
                                            :value="i.fundCode"
                                        >
                                        </el-option>
                                    </el-select> -->
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row" v-show="SHOW_SECURITY">
                            <el-col>
                                <el-form-item label="组合编码:">
                                    <el-select v-model="fundAccountCode" size="mini" style="width:100%" multiple collapse-tags>
                                        <el-option
                                            v-for="i in fundAccountCodeSelectData"
                                            :key="i.fundAccountCode"
                                            :label="i.fundAccountCode + ' ' + i.fundAccountName"
                                            :value="i.fundAccountCode"
                                        >
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col>
                                <el-form-item label="债券代码(以,分割):">
                                    <div
                                        class="risk-instruction-pledge-input-main"
                                        ref="inputVal"
                                        contentEditable="true"
                                        suppressContentEditableWarning="true"
                                        style="height: 100px; z-index: 5;"
                                        :key="renderUUID"
                                        @blur="handleChangeValue(e)"
                                    >
                                        <!-- {{ test }} -->
                                        <span v-for="(item, index) in valueNodes" :key="index" v-html="item"></span>
                                        <!-- {{ valueNodes }} -->
                                    </div>
                                    <div style="position: absolute; right: 3px; bottom: 7px; float: right; line-height: 20px; z-index: 10">
                                        <input
                                            type="button"
                                            style="border-radius: 5px; border: 1px solid black"
                                            value="识别"
                                            @click="handleChangeValue(e)"
                                        />
                                    </div>
                                    <!-- <el-input type="textarea" :rows="2" :value="riskOrderForm.stockCode" size="mini" @change="handleChangeValue"></el-input> -->
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col>
                                <el-form-item label="回购天数:">
                                    <el-input-number
                                        style="width: 100%"
                                        v-model="riskOrderForm.repoDay"
                                        :min="0"
                                        controls-position="right"
                                        size="mini"
                                        @change="handleRepoDayChange"
                                    ></el-input-number>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col>
                                <el-form-item label="清算速度:">
                                    <el-select v-model="riskOrderForm.clearSpeed" size="mini" @change="handleClearSpeedChange" style="width: 100%">
                                        <el-option v-for="i in clearSpeedSelectData" :key="i.dictKey" :label="i.dictKeyName" :value="i.dictKey">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col>
                                <el-form-item label="到期结算日期:"
                                    ><el-date-picker
                                        v-model="riskOrderForm.endSettleDate"
                                        type="date"
                                        format="yyyy-MM-dd"
                                        value-format="yyyyMMdd"
                                        style="width: 100%"
                                        placeholder="请选择"
                                        :picker-options="pickerOptions"
                                        @change="handleEndSettleDateChange"
                                    ></el-date-picker
                                ></el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col>
                                <el-form-item label="交易对手序号:">
                                    <el-select
                                        v-model="riskOrderForm.opponentCode"
                                        @change="getOpponentCode"
                                        filterable
                                        remote
                                        :remote-method="getOpponentCode"
                                        :loading="selectLoading"
                                        clearable
                                        size="mini"
                                        style="width: 100%"
                                    >
                                        <el-option
                                            v-for="i in opponentCodeSelectData"
                                            :key="i.dictKey"
                                            :label="i.dictKey + ' ' + i.dictKeyName"
                                            :value="i.dictKey"
                                        >
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                    <el-row class="form-row" style="float: right">
                        <el-button @click="handleClickButtonReset" size="mini">重置</el-button>
                        <el-button @click="handleSubmit('1')" type="primary" size="mini">试算</el-button>
                    </el-row>
                </el-form>
            </el-col>
            <el-col :span="16" class="col-box security-box" style="height: 100%">
                <h3 class="title" style="margin-top: 6px">质押券试算列表:<el-divider></el-divider></h3>
                <!-- <risk-table :msg="positionsListMsg" @getList="getPositionList"></risk-table> -->
                <div style="height: calc(100% - 30px)">
                    <vxe-table
                        :data="planDataSource"
                        border
                        show-header-overflow="tooltip"
                        show-overflow="tooltip"
                        :auto-resize="true"
                        resizable
                        height="100%"
                        size="mini"
                        style="width: 100%"
                        header-align="center"
                    >
                        <vxe-column type="checkbox" title="" width="50"></vxe-column>
                        <vxe-column type="seq" width="50" title="序号"></vxe-column>
                        <vxe-column field="stockCode" title="债券代码" show-overflow width="100px"> </vxe-column>
                        <vxe-column field="stockNameSt" title="债券名称" show-overflow width="100px"> </vxe-column>
                        <vxe-column field="pledgeRatio" title="质押比率" show-overflow width="120px">
                            <template slot-scope="scope">
                                <el-input-number
                                    v-model="scope.row.pledgeRatio"
                                    :precision="2"
                                    :min="0"
                                    controls-position="right"
                                    size="mini"
                                ></el-input-number>
                            </template>
                        </vxe-column>
                        <vxe-column field="stockTypeName" title="证券类别" show-overflow width="100px"></vxe-column>
                        <vxe-column field="inTypeName" title="利率类型" show-overflow width="100px"></vxe-column>
                        <vxe-column field="bDayTerm" title="期限/剩余期限(年)" show-overflow width="150px">
                            <template slot-scope="scope">
                                <span
                                    >{{ (numberFormat(scope.row.bDayTerm, '年') || '0') + '/' + (numberFormat(scope.row.bReDayTerm, '年') || '0') }}
                                </span>
                            </template>
                        </vxe-column>
                        <vxe-column field="facePrice" title="面额" show-overflow width="100px"></vxe-column>
                        <vxe-column field="rd2" title="下一行权日" show-overflow width="100px" align="center"> </vxe-column>
                        <vxe-column field="endDate" title="到期日" show-overflow width="100px" :formatter="formatEndDate" align="center">
                            <!-- <template slot-scope="scope">
                <span>{{
                  !scope.row.endDate || String(scope.row.endDate) === '0' ? '' : moment(scope.row.endDate, 'YYYYMMDD').format('YYYY-MM-DD')
                }}</span>
              </template> -->
                        </vxe-column>
                        <vxe-column field="nextPayDate" title="下一付息日" show-overflow width="100px" :formatter="formatNextPayDate"> </vxe-column>
                        <vxe-column field="stockInnerGradeName" title="债券内部评级" show-overflow width="150px">
                            <template slot-scope="scope">
                                <span>{{ (scope.row.stockInnerGradeName || '').replace('级', '') }}</span>
                            </template>
                        </vxe-column>
                        <vxe-column field="stockOuterGradeName" title="债券外部评级" show-overflow width="150px"></vxe-column>
                        <vxe-column field="issueInnerGradeName" title="发行人内部评级" show-overflow width="150px"></vxe-column>
                        <vxe-column field="issueOuterGradeName" title="发行人外部评级" show-overflow width="150px"></vxe-column>
                        <vxe-column field="dValue" title="日期差值" show-overflow width="100px" :formatter="formatDValue" align="center"></vxe-column>
                        <vxe-column
                            field="rd1"
                            title="下一还本/行权/到期日"
                            show-overflow
                            width="180px"
                            :formatter="formatRd1"
                            align="center"
                        ></vxe-column>
                        <vxe-column field="nextRepaymentDate" title="下一还本日" show-overflow width="150px" align="center"></vxe-column>
                    </vxe-table>
                </div>
            </el-col>
        </el-row>

        <el-row class="row-height bottom-row">
            <el-col class="col-box" style="height: 100%">
                <h3 class="title">
                    <el-row>
                        <el-col :span="3">风控结果:<status-tag :code="riskResult"></status-tag></el-col>
                        <el-col :span="5">
                            <span>试算/下单时间: </span>
                            <span style="color: red">{{ calcTime }}</span>
                        </el-col>
                        <el-col :span="5">
                            <span>计算耗时: </span>
                            <span style="color: red">{{ takeTime }}</span>
                        </el-col>
                        <el-col :span="7"
                            >条目检查数:
                            <span v-show="riskResultSourceList.length" style="color: red">{{ riskResultSourceList.length }}</span></el-col
                        >
                        <el-col :span="4">
                            <div>
                                <el-checkbox v-model="thresholdTypeFilter['1']" @change="handelThresholdTypeFilter('1')">显示触警</el-checkbox>
                                <el-checkbox v-model="thresholdTypeFilter['0']" @change="handelThresholdTypeFilter('0')">显示合规</el-checkbox>
                            </div>
                        </el-col>
                    </el-row>
                    <el-divider></el-divider>
                </h3>

                <!-- <risk-table :msg="riskResListMsg"></risk-table> -->
                <div style="height: calc(100% - 27px)">
                    <vxe-table
                        v-if="tableKey"
                        :data="riskResListMsg.returnData.data"
                        :column-config="{ isHover: true }"
                        :row-config="{ isHover: true }"
                        :sort-config="{ trigger: 'cell', defaultSort: { field: 'thresholdType', order: 'desc' }, orders: ['desc', 'asc', null] }"
                        border
                        size="mini"
                        style="width: 100%"
                        height="100%"
                        auto-resize
                        header-align="center"
                        show-header-overflow
                        show-overflow
                        resizable
                    >
                        <vxe-column field="fundCode" title="产品代码" sortable width="120" :filters="[{ data: '' }]" :filter-method="filterHandler">
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="fundNameSt"
                            title="产品名称"
                            min-width="120"
                            show-overflow
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                        >
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="assetCode"
                            title="资产单元编号"
                            sortable
                            width="140"
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                            v-if="SHOW_SECURITY"
                        >
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                            <template slot-scope="scope">
                                <span>{{ scope.row.assetCode || '--' }}</span>
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="assetName"
                            title="资产单元名称"
                            min-width="120"
                            show-overflow
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                            v-if="SHOW_SECURITY"
                        >
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                            <template slot-scope="scope">
                                <span>{{ scope.row.assetName || '--' }}</span>
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="fundAccountCode"
                            title="组合编码"
                            sortable
                            width="120"
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                            v-if="SHOW_SECURITY"
                        >
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                            <template slot-scope="scope">
                                <span>{{ scope.row.fundAccountCode || '--' }}</span>
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="fundAccountName"
                            title="组合名称"
                            min-width="120"
                            show-overflow
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                            v-if="SHOW_SECURITY"
                        >
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                            <template slot-scope="scope">
                                <span>{{ scope.row.fundAccountName || '--' }}</span>
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="stockCode"
                            title="证券代码"
                            sortable
                            show-overflow
                            min-width="150"
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                        >
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                        </vxe-column>
                        <vxe-column field="stockNameSt" title="证券名称" width="120" :filters="[{ data: '' }]" :filter-method="filterHandler">
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="entryCode"
                            title="条目编号"
                            sortable
                            min-width="120"
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                        >
                            <template #filter="{ $panel, column }">
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="entryName"
                            title="风险说明"
                            :filters="[{ data: '' }]"
                            :filter-method="filterHandler"
                            show-overflow
                            min-width="130"
                        >
                            <template #filter="{ $panel, column }">
                                <div>
                                    <el-input
                                        class="my-input"
                                        type="type"
                                        v-for="(option, index) in column.filters"
                                        :key="index"
                                        v-model="option.data"
                                        @input="$panel.changeOption($event, !!option.data, option)"
                                    />
                                </div>
                            </template>
                        </vxe-column>
                        <vxe-column
                            field="thresholdType"
                            title="阈值类型"
                            sortable
                            width="130"
                            :filters="ThresholdTypeArr"
                            :filter-method="filterThresholdType"
                        >
                            <template slot-scope="scope">
                                <status-tag :code="scope.row.thresholdType" />
                            </template>
                        </vxe-column>
                    </vxe-table>
                </div>
            </el-col>
        </el-row>

        <yh-dialog drag title="选择条目组" :visible.sync="transDialog" width="700px">
            <el-row>
                <el-col :span="11">
                    <div>
                        <el-table
                            ref="leftTable"
                            :data="dataSourceLeft"
                            tooltip-effect="dark"
                            style="width: 100%"
                            height="400px"
                            row-key="groupCode"
                            border
                            @selection-change="handleSelectionLeftChange"
                        >
                            <el-table-column type="selection" width="40" align="center" :reserve-selection="true"></el-table-column>
                            <el-table-column
                                v-for="col in tranColumns"
                                :key="col.prop"
                                :prop="col.prop"
                                :label="col.label"
                                :width="col.width"
                                show-overflow-tooltip
                            ></el-table-column>
                        </el-table>
                    </div>
                </el-col>
                <el-col :span="2">
                    <div class="trant-but">
                        <el-button type="primary" icon="el-icon-arrow-right" size="mini" @click="handleMoveToData('LTCR')"></el-button>
                        <br />
                        <el-button type="primary" icon="el-icon-arrow-left" size="mini" @click="handleMoveToData('CRTL')"></el-button>
                    </div>
                    <div>
                        <el-button type="primary" icon="el-icon-arrow-right" size="mini" @click="handleMoveToData('LTER')"></el-button>
                        <br />
                        <el-button type="primary" icon="el-icon-arrow-left" size="mini" @click="handleMoveToData('ERTL')"></el-button>
                    </div>
                </el-col>
                <el-col :span="11">
                    <div>
                        <h3>计算以下条目组：</h3>
                        <el-table
                            ref="rightTable1"
                            :data="dataSourceCalculateRight"
                            @selection-change="handleSelectionrightChange1"
                            tooltip-effect="dark"
                            style="width: 100%"
                            height="180px"
                            row-key="groupCode"
                            border
                        >
                            <el-table-column type="selection" width="40" align="center" :reserve-selection="true"></el-table-column>
                            <el-table-column
                                v-for="col in tranColumns"
                                :key="col.prop"
                                :prop="col.prop"
                                :label="col.label"
                                :width="col.width"
                                show-overflow-tooltip
                            ></el-table-column>
                        </el-table>
                    </div>
                    <div>
                        <h3>排除以下条目组：</h3>

                        <el-table
                            ref="rightTable2"
                            :data="dataSourceExcludeRight"
                            @selection-change="handleSelectionrightChange2"
                            tooltip-effect="dark"
                            style="width: 100%"
                            height="180px"
                            row-key="groupCode"
                            border
                        >
                            <el-table-column type="selection" width="40" align="center" :reserve-selection="true"></el-table-column>
                            <el-table-column
                                v-for="col in tranColumns"
                                :key="col.prop"
                                :prop="col.prop"
                                :label="col.label"
                                :width="col.width"
                                show-overflow-tooltip
                            ></el-table-column>
                        </el-table>
                    </div>
                </el-col>
            </el-row>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="transDialog = false"> 取 消 </el-button>
                <el-button size="mini" type="primary" @click="handleEntrySubmit"> 确 定 </el-button>
            </div>
        </yh-dialog>
    </div>
</template>
<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator';
import RiskTable from '@/common/components/risk-table.vue';
import { SGU_CACHE, objToArr } from '@/utils/diction-const-util';
import Invest from '@/common/dict/invest';
import { UUID, NumberToWords, getCurrentPageData, PrefixInteger, numberFormat, getConfigItem } from '@/utils/tools';
import StatusTag from '@/pages/risk-measure/components/status-tag.vue';
import { getActiveMenuCode, getUser } from '@/utils/user-util';
import XEUtils from 'xe-utils';
import moment from 'moment';
import RiskCustomSelect from '@/common/components/risk-custom-select.vue';
import RiskEntryInputs from '@/common/components/risk-entry-inputs.vue';
export interface pages {
    total?: number;
    pageSize?: number;
    currentPage?: number;
}

@Component({
    name: 'Pledge',
    components: { RiskTable, StatusTag, RiskCustomSelect, RiskEntryInputs },
})
// 质押券试算
export default class Pledge extends Vue {
    SHOW_SECURITY = getConfigItem('SHOW_SECURITY');

    numberFormat = numberFormat;
    // 风控指令表单
    riskOrderForm = {
        fundCodes: [],
        endSettleDate: '',
        clearSpeed: '0',
        repoDay: null,
        reportCode: '',
        stockCode: '',
        opponentCode: '',
    };
    tableKey: number = 0;

    Invest: any = new Invest();
    ThresholdTypeArr: any[] = [];

    fundCodeSelectData: any[] = []; // 产品序号下拉框数据

    stockCodeSelectData: any[] = []; // 证券代码下拉框数据

    allStockType: any[] = []; // 所有订单方向数据

    allOrderDirection: any[] = [];

    selectLoading: boolean = false; // 下拉框远程搜索时的加载状态

    opponentCodeSelectData: any[] = []; // 交易对手方下拉数据

    calcTime: string = ''; // 下单/试算时间

    takeTime: string | number = ''; // 计算耗时

    riskResult: string | number = ''; // 风控结果

    entryType = {}; // 风险类型字典

    compareDirection = {}; // 比较方向字典

    clearSpeedSelectData: any[] = []; // 清算速度下拉数据

    pickerOptions: any = {
        disabledDate(time) {
            return time.getTime() < Date.now() - 1 * 24 * 3600 * 1000;
        },
    };

    private thresholdTypeFilter: any = {
        '0': false,
        '1': true,
    };

    // 证券代码下拉框数据相关
    stockCodeMsg = {
        url: '/dict/stock/select',
    };

    // 证券信息相关
    stockMessageMsg = { url: '/baseInfomation/stockCode/', returnData: {} };

    // 持仓信息相关
    positionsListMsg = {
        url: '/baseInfomation/pledge/order/stock/',
        returnData: { data: [], total: 0 },
        dataKey: 'data',
        title: [
            // { name: '', type: 'checkbox', width: 50 },
            { name: '序号', type: 'index', width: 110 },
            { name: '债券代码', val: 'stockCode', width: 110 },
            { name: '债券名称', val: 'stockNameSt', width: 110 },
            { name: '质押比率', type: 'numberInput', val: 'pledgeRatio', width: 110 },
            { name: '证券类别', val: 'stockTypeName', width: 110 },
            { name: '利率类型', val: 'inTypeName', width: 80 },
            { name: '期限/剩余期限(年)', val: 'bDayTerm', width: 80 },
            { name: '面额', val: 'facePrice', width: 110, type: 'func', funcBody: value => (value != undefined ? numberFormat(value, 2) : '--') },
            { name: '下一行权日', val: 'rd2', width: 110 },
            { name: '到期日', val: 'endDate', width: 110, type: 'status', statusKV: this.Invest.bullbearType },
            { name: '下一付息日', val: 'nextPayDate', width: 110 },
            { name: '债券内部评级', val: 'stockInnerGradeName', width: 110 },
            { name: '债券外部评级', val: 'stockOuterGradeName', width: 110 },
            { name: '发行人内部评级', val: 'issueInnerGradeName', width: 110 },
            { name: '发行人外部评级', val: 'issueOuterGradeName', width: 110 },
            { name: '日期差值', val: 'dValue', width: 110 },
            { name: '下一还本/行权/到期日', val: 'rd1', width: 110 },
            { name: '下一还本日', val: 'nextRepaymentDate', width: 110 },
        ],
        height: '250px',
        // 隐藏页码
        hidePage: false,
        checked: { on: true, option: false },
    };
    // 风控结果相关
    riskResListMsg = {
        url: '/dataEngine/order/multiOrder',
        returnData: { data: [] },
        dataKey: 'data',
        title: [
            { name: '产品代码', val: 'fundCode', sortable: true, search: true, filters: [{ data: '' }] },
            { name: '产品名称', val: 'fundNameSt', search: true, filters: [{ data: '' }] },
            { name: '证券代码', val: 'stockCode', sortable: true, search: true, filters: [{ data: '' }] },
            { name: '证券名称', val: 'stockNameSt', search: true, filters: [{ data: '' }] },
            { name: '条目编号', val: 'entryCode', sortable: true, search: true, filters: [{ data: '' }] },
            { name: '风险说明', val: 'entryName', search: true, filters: [{ data: '' }] },
            { name: '阈值类型', val: 'thresholdType', type: 'statusTag', sortable: true, filters: this.objToArr(this.Invest.ThresholdType) },
        ],
        height: '350px',
        // 隐藏页码
        hidePage: true,
        checked: { on: false, option: false },
    };
    positionList: any[] = [];

    tradeDays: any[] = [];
    valueNodes: any;
    stockDataList: any[] = [];
    TimeOutStock = null;

    endDatePicker: any;
    selectRowKeys: any[] = [];
    renderUUID: string = '-1';
    test: any;
    // 条目组穿梭框
    transDialog: boolean = false;

    // 模块详情穿梭框数据
    private tranColumns: any[] = [
        {
            label: '编号',
            prop: 'groupCode',
            width: 80,
        },
        {
            label: '名称',
            prop: 'groupName',
        },
    ];

    dataSourceLeft: any[] = [];
    dataSourceCalculateRight: any[] = [];
    dataSourceExcludeRight: any[] = [];
    selectKeyLeft: any[] = []; // 左边选中的key
    selectKeyCalculateRight: any[] = []; // 右边选中的key
    selectKeyExcludeRight: any[] = []; // 右边选中排除的key
    entryGroups: any;

    selectEntryGroupCode = {
        calculateEntryGroup: [],
        excludeEntryGroup: [],
    };
    planDataSource: any[] = [];
    funds: any[] = [];
    private fundCodesNumKey: number = -1;
    // 图标dom
    private iconDom: any = null;
    stockInfoPojo: any = {};
    currentDate: number;

    riskResultSourceTable: any[] = [];
    riskResultSourceList: any[] = [];
    planDataPojo: any = {};
    resourceCode: string = '';
    fundAccountCode: any[] = [];
    fundAccountCodeSelectData: any[] = []; // 组合编码下拉框数据
    fundAccountCodeSelectDataAll: any[] = [];
    @Watch('riskOrderForm.fundCodes')
    handleFundCodes() {
        let data = [];
        this.riskOrderForm.fundCodes.map(key => {
            data = data.concat(this.fundAccountCodeSelectDataAll[key] || []);
            return key;
        });
        this.fundAccountCodeSelectData = data;
    }
    async mounted() {
        let arr = await SGU_CACHE('FundAccount', '/fundInfo/accounts', []);
        arr.forEach(item => {
            this.fundAccountCodeSelectDataAll[item.fundCode] = item.fundAccounts;
        });
        this.resourceCode = getActiveMenuCode().defaultActive;

        // 获取产品信息 (产品序号下拉框数据)
        this.fundCodeSelectData = await SGU_CACHE('FundInfo', '/fundInfo/list', []);

        for (let i = 0; i < this.fundCodeSelectData.length; i++) {
            this.funds.push({
                dictKey: this.fundCodeSelectData[i].fundCode,
                dictKeyName: this.fundCodeSelectData[i].fundNameSt,
                showCode: this.fundCodeSelectData[i].showCode,
            });
        }
        this.fundCodesNumKey++;

        this.ThresholdTypeArr = this.objToArr(this.Invest.ThresholdType);

        // 获取证券代码下拉框数据
        this.getstockCodeList();
        // 获取所有证券类别 (用于筛选订单方向)
        this.allStockType = await SGU_CACHE('StockType', '/dict/stockType/list', []);
        // 获取清算速度下拉数据
        this.clearSpeedSelectData = objToArr(this.Invest.clearSpeed);
        // 获取交易对手方
        this.getOpponentCode('');

        // 获取当前日期
        this.currentDate = Number(XEUtils.toDateString(new Date(), 'yyyyMMdd'));

        // 交易日期获取 获取未来150天的交易日期
        this.getSystemTradeDay();

        this.getEntryGroupList();
        this.getUserSelectEntryGroupList();
        this.changeTable();
        this.tableKey++;
    }

    openTransDialog() {
        this.transDialog = true;
        this.getEntryGroupList();
        this.getUserSelectEntryGroupList();
    }

    // 查询未来150天的交易日期
    getSystemTradeDay() {
        this.$axios.get('/baseInfomation/system/trade/day').then((res: any) => {
            this.tradeDays = res.map(item => Number(item)).sort((a, b) => a - b);
        });
    }

    private handelThresholdTypeFilter() {
        this.riskResultSourceTable = this.riskResultSourceList.filter(
            item => (this.thresholdTypeFilter['1'] && item.thresholdType !== '0') || (this.thresholdTypeFilter['0'] && item.thresholdType === '0')
        );
        this.riskResListMsg.returnData.data = this.riskResultSourceTable;
    }

    handleRepoDayChange(e) {
        let fundInfo = this.riskOrderForm;
        fundInfo.repoDay = e;
        fundInfo.endSettleDate = this.calcEndSettleDate(fundInfo).toString();
        fundInfo.stockCode = this.vistualStockCode(fundInfo);
        fundInfo.reportCode = this.vistualReportCode(fundInfo);
        this.riskOrderForm = JSON.parse(JSON.stringify(fundInfo));
    }

    handleEndSettleDateChange(e) {
        let fundInfo = this.riskOrderForm;
        fundInfo.endSettleDate = e;
        fundInfo.repoDay = this.calcRepoDay(fundInfo);
        fundInfo.stockCode = this.vistualStockCode(fundInfo);
        fundInfo.reportCode = this.vistualReportCode(fundInfo);
        this.riskOrderForm = JSON.parse(JSON.stringify(fundInfo));
    }
    handleClearSpeedChange(e) {
        let fundInfo = this.riskOrderForm;
        fundInfo.clearSpeed = e;
        if (fundInfo.repoDay) {
            fundInfo.endSettleDate = this.calcEndSettleDate(fundInfo).toString();
        } else {
            fundInfo.repoDay = this.calcRepoDay(fundInfo);
        }
        fundInfo.stockCode = this.vistualStockCode(fundInfo);
        fundInfo.reportCode = this.vistualReportCode(fundInfo);
        this.riskOrderForm = JSON.parse(JSON.stringify(fundInfo));
    }
    changeTable() {
        this.$nextTick(() => {
            if (!this.iconDom) {
                this.iconDom = document.querySelectorAll('.vxe-icon--funnel');
                for (let i = 0; i < 6; i++) {
                    this.iconDom[i].className = 'vxe-filter--btn el-icon-search';
                }
            }
        });
    }

    formatEndDate({ cellValue }) {
        return !cellValue || String(cellValue) === '0' ? '' : moment(cellValue, 'YYYYMMDD').format('YYYY-MM-DD');
    }

    formatNextPayDate({ cellValue }) {
        if (!cellValue || String(cellValue) === '0' || Number(cellValue) < this.currentDate) {
            return '';
        } else {
            return moment(cellValue, 'YYYYMMDD').format('YYYY-MM-DD');
        }
    }

    formatDValue({ cellValue, row }) {
        let endSettleDate = this.riskOrderForm.endSettleDate;
        // 行权日
        let resaleDate = Number(row.resaleDate || 0);
        let redemDate = Number(row.redemDate || 0);
        // 到期日
        let endDate = Number(row.endDate || 0);
        // 最近还本
        let nextRepaymentDate = Number(row.nextRepaymentDate || 0);
        let cc = Math.min(...[resaleDate, redemDate, endDate, nextRepaymentDate].filter(item => item !== 0));
        if (endSettleDate && cc) {
            let res = moment(cc, 'YYYYMMDD').diff(moment(endSettleDate, 'YYYYMMDD'), 'day');
            if (res <= 1) {
                return res;
                // return `<span style="color: red">${res}</span>`;
            } else {
                return res;
            }
        } else {
            return '';
        }
    }

    formatRd1({ cellValue, row }) {
        // 行权日
        let resaleDate = Number(row.resaleDate || 0);
        let redemDate = Number(row.redemDate || 0);
        // 到期日
        let endDate = Number(row.endDate || 0);
        // 最近还本
        let nextRepaymentDate = Number(row.nextRepaymentDate || 0);
        return Math.min(...[resaleDate, redemDate, endDate, nextRepaymentDate].filter(item => item !== 0));
    }

    /**
     * 虚拟证券代码
     */
    vistualStockCode(instruction) {
        if (Number(instruction.repoDay || 0) === 0) {
            return '';
        }
        return 'R' + PrefixInteger(Number(instruction.repoDay || 0), 3) + ' YH';
    }
    /**
     * 虚拟申报代码
     */
    vistualReportCode(instruction) {
        if (Number(instruction.repoDay || 0) === 0) {
            return '';
        }
        return 'R' + PrefixInteger(Number(instruction.repoDay || 0), 3);
    }
    /**
     * 回购天数计算公式
     */
    calcRepoDay(instruction) {
        if (!instruction.endSettleDate) {
            return '';
        } else {
            return Math.ceil(
                moment(instruction.endSettleDate, 'YYYYMMDD').diff(moment().add(Number(instruction.clearSpeed), 'd'), 'seconds') / 3600 / 24
            );
        }
    }
    /**
     * 到期日期计算公式
     */
    calcEndSettleDate(instruction) {
        if (Number(instruction.repoDay || 0) === 0) {
            return '';
        } else {
            return this.tradeDays.find(
                item =>
                    item >=
                    Number(
                        moment()
                            .add(Number(instruction.repoDay) + Number(instruction.clearSpeed), 'd')
                            .format('YYYYMMDD')
                    )
            );
        }
    }

    /**
     * 到期日期限制
     */
    disabledDate(endValue) {
        if (!endValue) {
            return false;
        }
        return parseInt(endValue.format('YYYYMMDD')) >= parseInt(moment().format('YYYYMMDD'));
    }

    /**
     * 债券代码
     */
    handleChangeValue(e) {
        let factValue = (this.$refs.inputVal as any).innerText;
        if (this.TimeOutStock) {
            clearTimeout(this.TimeOutStock);
            this.TimeOutStock = null;
        }
        this.TimeOutStock = setTimeout(() => {
            if (!factValue || factValue.trim().length === 0) {
                this.stockDataList = [];
                this.valueNodes = [];
                this.selectRowKeys = [];
                this.renderUUID = UUID();
                this.planDataSource = [];
                // this.setState({
                //   renderUUID: UUID(),
                //   planDataSource: [],
                //   selectRowKeys: [],
                //   valueNodes: [],
                // });
                return;
            }
            let dataList = factValue
                .replace(/\n/g, '')
                .replace('，', ',')
                .split(',')
                .filter(item => !!item.trim());
            if (!dataList || dataList.length === 0) {
                return;
            }
            this.$axios.post('/baseInfomation/pledge/order/stock', dataList).then((res: any) => {
                res.forEach(item => {
                    item.key = item.stockCode;
                    item.pledgeRatio = 1;
                });
                this.stockDataList = dataList;
                this.planDataSource = res;
                // this.positionsListMsg.returnData.data = res;
                this.valueNodes = this.createInputNode(dataList, res);
                this.selectRowKeys = res.map((item: any) => item.stockCode);
                this.test = this.valueNodes[0];
                this.renderUUID = UUID();
            });
        }, 1000);
    }

    /**
     * 生成输入框节点元素
     */
    createInputNode(dataList, dataSource) {
        let reportCodes = dataSource.map(item => item.reportCode);
        let innerHTML = [];
        for (let keyValue of dataList) {
            if (reportCodes.includes(keyValue)) {
                innerHTML.push(`<span key=${'A' + keyValue}>${keyValue}</span>`);
            } else {
                innerHTML.push(`<span key=${'B' + keyValue} style="color: red">${keyValue}</span>`);
            }
            innerHTML.push(`<span key=${'C' + keyValue}>,</span>`);
            innerHTML.push(`<br />`);
        }
        return innerHTML;
    }

    // 转表格筛选下拉框数据
    objToArr(param) {
        let list = [];
        for (let key in param) {
            list.push({ label: param[key], value: key });
        }
        return list;
    }

    // 证券代码选中事件 => 请求 证券信息 & 订单方向
    handleStockCode(e) {
        this.$axios(this.stockMessageMsg.url + e).then((res: any) => {
            if (res) {
                this.stockMessageMsg.returnData = res;
            }
        });
        let st = this.stockCodeSelectData.find(item => item.stockCode === e);
        this.stockInfoPojo[e] = st.stockNameSt;

        let stockType = null;
        for (let i = 0; i < this.stockCodeSelectData.length; i++) {
            const ele = this.stockCodeSelectData[i];
            if (ele.stockCode === e) {
                stockType = ele.stockType;
                // this.riskOrderForm.marketCode = ele.marketCode;
                this.riskOrderForm.reportCode = ele.reportCode;
                // this.riskOrderForm.stockType = ele.stockType;
                break;
            }
        }
    }

    // 获取证券代码下拉框数据
    getstockCodeList() {
        this.selectLoading = true;
        this.$axios
            .post('/dict/stock/select/' + 1, {
                dictKey: '',
                dictKeyName: '',
            })
            .then((res: any) => {
                this.stockCodeSelectData = res || [];
                this.selectLoading = false;
            });
    }

    getUserSelectEntryGroupList() {
        this.$axios.get('/entry/group/user/select/list/' + this.resourceCode).then((res: any) => {
            res = res || [];
            this.selectEntryGroupCode = {
                calculateEntryGroup: res.filter(item => item.instGroupType === '1' && item.groupCode !== 'DEFAULT').map(item => item.groupCode),
                excludeEntryGroup: res.filter(item => item.instGroupType === '2' && item.groupCode !== 'DEFAULT').map(item => item.groupCode),
            };
            this.initData(this.selectEntryGroupCode);
        });
    }

    getEntryGroupList() {
        this.$axios.get('/entry/group/list').then((res: any) => {
            console.log(res);

            this.entryGroups = res.map(item => {
                return {
                    key: item.groupCode,
                    groupCode: item.groupCode,
                    groupName: item.groupName,
                };
            });
            this.entryGroups = this.entryGroups.filter(item => {
                return item.groupCode !== 'DEFAULT';
            });
        });
    }

    /**
     * 数据初始化
     */
    initData(selectEntryGroupCode) {
        let entryGroups = this.entryGroups || [];
        let calculateEntryGroup = (selectEntryGroupCode || []).calculateEntryGroup;
        let excludeEntryGroup = (selectEntryGroupCode || []).excludeEntryGroup;
        this.dataSourceLeft = entryGroups.filter(
            item => !calculateEntryGroup.includes(item.groupCode) && !excludeEntryGroup.includes(item.groupCode)
        );
        this.dataSourceCalculateRight = entryGroups.filter(item => calculateEntryGroup.includes(item.groupCode));
        this.dataSourceExcludeRight = entryGroups.filter(item => excludeEntryGroup.includes(item.groupCode));
        // this.setState({
        //     dataSourceLeft: dataSourceLeft,
        //     dataSourceCalculateRight: dataSourceCalculateRight,
        //     dataSourceExcludeRight: dataSourceExcludeRight,
        //     selectKeyCalculateRight: [],
        //     selectKeyExcludeRight: [],
        // })
    }

    handleSelectionLeftChange(val: any) {
        this.selectKeyLeft = [];
        val.forEach(ele => {
            this.selectKeyLeft.push(ele.groupCode);
        });
    }

    handleSelectionrightChange1(val: any) {
        this.selectKeyCalculateRight = [];
        val.forEach(ele => {
            this.selectKeyCalculateRight.push(ele.groupCode);
        });
    }

    handleSelectionrightChange2(val: any) {
        this.selectKeyExcludeRight = [];
        val.forEach(ele => {
            this.selectKeyExcludeRight.push(ele.groupCode);
        });
    }

    /**
     * 左边数据放到右边
     */
    handleMoveToData(type) {
        let dataSourceLeft = JSON.parse(JSON.stringify(this.dataSourceLeft));
        let dataSourceCalculateRight = JSON.parse(JSON.stringify(this.dataSourceCalculateRight));
        let dataSourceExcludeRight = JSON.parse(JSON.stringify(this.dataSourceExcludeRight));
        let selectKeyLeft = JSON.parse(JSON.stringify(this.selectKeyLeft));
        let selectKeyCalculateRight = JSON.parse(JSON.stringify(this.selectKeyCalculateRight));
        let selectKeyExcludeRight = JSON.parse(JSON.stringify(this.selectKeyExcludeRight));
        if (type === 'LTCR') {
            if (selectKeyLeft.length === 0) {
                return;
            }
            let value = dataSourceLeft.filter(item => selectKeyLeft.includes(item.groupCode));
            dataSourceLeft = dataSourceLeft.filter(item => !selectKeyLeft.includes(item.groupCode));
            dataSourceCalculateRight = value.concat(dataSourceCalculateRight);

            selectKeyLeft = [];
        } else if (type === 'CRTL') {
            if (selectKeyCalculateRight.length === 0) {
                return;
            }
            let value = dataSourceCalculateRight.filter(item => selectKeyCalculateRight.includes(item.groupCode));
            dataSourceCalculateRight = dataSourceCalculateRight.filter(item => !selectKeyCalculateRight.includes(item.groupCode));
            dataSourceLeft = value.concat(dataSourceLeft);
            selectKeyCalculateRight = [];
        } else if (type === 'LTER') {
            if (selectKeyLeft.length === 0) {
                return;
            }
            let value = dataSourceLeft.filter(item => selectKeyLeft.includes(item.groupCode));
            dataSourceLeft = dataSourceLeft.filter(item => !selectKeyLeft.includes(item.groupCode));
            dataSourceExcludeRight = value.concat(dataSourceExcludeRight);
            selectKeyLeft = [];
        } else if (type === 'ERTL') {
            if (selectKeyExcludeRight.length === 0) {
                return;
            }
            let value = dataSourceExcludeRight.filter(item => selectKeyExcludeRight.includes(item.groupCode));
            dataSourceExcludeRight = dataSourceExcludeRight.filter(item => !selectKeyExcludeRight.includes(item.groupCode));
            dataSourceLeft = value.concat(dataSourceLeft);
            selectKeyExcludeRight = [];
        }
        // this.setState({
        this.dataSourceLeft = JSON.parse(JSON.stringify(dataSourceLeft));
        this.dataSourceCalculateRight = JSON.parse(JSON.stringify(dataSourceCalculateRight));
        this.dataSourceExcludeRight = JSON.parse(JSON.stringify(dataSourceExcludeRight));
        this.selectKeyCalculateRight = JSON.parse(JSON.stringify(selectKeyCalculateRight));
        this.selectKeyExcludeRight = JSON.parse(JSON.stringify(selectKeyExcludeRight));
        // })
    }

    /**
     * 筛选条件 事件
     */
    // handelThresholdTypeFilter = (checked, field) => {
    //     let thresholdTypeFilter = this.thresholdTypeFilter;
    //     thresholdTypeFilter[field] = checked
    // }

    // 重置按钮点击事件
    handleClickButtonReset() {
        this.riskOrderForm = {
            fundCodes: [],
            endSettleDate: '',
            clearSpeed: '0',
            repoDay: '',
            reportCode: '',
            stockCode: '',
            opponentCode: '',
        };
        this.stockMessageMsg.returnData = {};
        // this.positionsListMsg.returnData.data = [];
        // this.positionsListMsg.returnData.total = 0;
        this.planDataSource = [];
        this.selectRowKeys = [];
        this.valueNodes = [];
        this.fundCodesNumKey++;
    }

    handleEntrySubmit() {
        let dataSourceCalculateRight = this.dataSourceCalculateRight;
        let dataSourceExcludeRight = this.dataSourceExcludeRight;
        let dataParam = dataSourceCalculateRight
            .map(item => {
                return { groupCode: item.groupCode, instGroupType: '1' };
            })
            .concat(
                dataSourceExcludeRight.map(item => {
                    return { groupCode: item.groupCode, instGroupType: '2' };
                })
            );

        this.$axios.post('/entry/group/user/select/insert/' + this.resourceCode, dataParam).then(res => {
            this.transDialog = false;
            this.yh_message_success('保存成功');
            this.getUserSelectEntryGroupList();
        });
    }

    getPositionList(pages) {
        this.positionsListMsg.returnData.data = getCurrentPageData(this.positionList, pages.currentPage, pages.pageSize);
    }

    // 获取交易对手方信息
    private getOpponentCode(value: string) {
        this.$axios
            .post('/dict/opponent/select', {
                dictKey: value,
                dictKeyName: value,
            })
            .then((res: any) => {
                this.opponentCodeSelectData = res;
            });
    }

    // 校验提交参数

    // 提交事件
    handleSubmit(orderType: string) {
        if (this.selectRowKeys.length === 0) {
            this.yh_message_warn('请输入债券进行试算！');
            return;
        }
        let fundInfo: any = this.riskOrderForm;
        if (!fundInfo.fundCodes || fundInfo.fundCodes.length === 0) {
            this.yh_message_warn('产品代码不可为空！');
            return;
        }

        let planDataSource = this.planDataSource.filter(item => this.selectRowKeys.includes(item.stockCode));
        let pldgeData = planDataSource.map(item => {
            return {
                marketCode: '5',
                reportCode: item.reportCode,
                pledgedQty: '1',
                investType: '1',
                pledgeRatio: item.pledgeRatio,
                fundAccountCode: ' ',
            };
        });

        let instruction = fundInfo.fundCodes.map((item, i) => {
            return JSON.stringify({
                isPled: '1',
                trailOnly: '1',
                clearSpeed: fundInfo.clearSpeed,
                orderType: '1',
                outerOrderCode: UUID() + i + '-' + new Date().getTime(),
                fundCode: item,
                fundAccountCode: ' ',
                orderPurpose: '1',
                investType: '1',
                orderDirection: '6',
                orderPriceType: '2',
                orderBalance: '0',
                orderAmount: '0',
                orderPrice: '0',
                orderLevel: '0',
                marketCode: '5',
                remark: ' ',
                settleType: '1',
                instructionType: '2',
                endSettleDate: fundInfo.endSettleDate,
                repoDay: fundInfo.repoDay,
                orderUser: getUser().userCode,
                opponentCode: fundInfo.opponentCode,
                pledgePOList: pldgeData,
            });
        });
        // 计算耗时
        let start = window.performance.now();

        // 获取当前提交时间 (试算/下单时间)
        // 补零
        let fillZero = n => {
            let result = n.toString().length === 1 ? '0' + n : n;
            return result;
        };
        // 时间戳转换 yyyy-MM-dd
        let formatTime = (t = new Date()) => {
            let d = new Date(t);
            let year = d.getFullYear();
            let month = d.getMonth() + 1;
            let date = d.getDate();
            let hours = d.getHours();
            let minutes = d.getMinutes();
            let seconds = d.getSeconds();
            let result = `${year}-${fillZero(month)}-${fillZero(date)} ${fillZero(hours)}:${fillZero(minutes)}:${fillZero(seconds)}`;
            return result;
        };
        this.calcTime = formatTime(new Date());

        // 提交指令 => 获取风控结果
        this.$axios
            .post(this.riskResListMsg.url, {
                requestId: UUID() + '-' + new Date().getTime(),
                directMode: '1',
                multiType: '1',
                orderType: '1',
                instructionType: '2',
                outOrderBatchCode: UUID() + '-' + new Date().getTime(),
                tradeUser: getUser().userCode,
                calculateEntryGroup: this.selectEntryGroupCode.calculateEntryGroup,
                excludeEntryGroup: this.selectEntryGroupCode.excludeEntryGroup,
                instList: instruction,
            })
            .then((res: any) => {
                let reValue = [];
                if (res) {
                    let planDataSource = this.planDataSource;
                    let planDataPojo = {};
                    for (let i = 0; i < planDataSource.length; i++) {
                        planDataPojo[planDataSource[i].stockCode] = {
                            index: i + 1,
                            stockCode: planDataSource[i].stockCode,
                            stockNameSt: planDataSource[i].stockNameSt,
                        };
                    }
                    this.planDataPojo = planDataPojo;
                    console.log(planDataPojo, 'pojo');

                    // 组装汇总指令
                    let totleResult = res.resultList || [];
                    let cvIndex = 0;
                    for (let listValue of totleResult) {
                        let tnf = this.funds.find(item2 => item2.dictKey === listValue.fundCode);
                        reValue.push({
                            key: listValue.entryKey + listValue.groupCode + res.requestId,
                            requestId: res.requestId,
                            index: planDataPojo[listValue.stockCode].index,
                            fundCode: tnf.dictKey,
                            fundNameSt: tnf.dictKeyName,
                            entryCode: listValue.entryCode,
                            entryName: listValue.entryName,
                            thresholdType: listValue.thresholdType,
                            thresholdValue: listValue.thresholdValue,
                            calculateValue: listValue.calculateValue,
                            stockCode: listValue.stockCode,
                            stockNameSt: planDataPojo[listValue.stockCode].stockNameSt,
                            branchNum: listValue.branchNum,
                            entryKey: listValue.entryKey,
                        });
                        cvIndex = cvIndex + 1;
                    }
                }
                reValue.sort((a, b) => Number(b.thresholdType) - Number(a.thresholdType));
                this.yh_message_success('指令信息提交成功');
                // 风控结果
                this.riskResult = res.thresholdType;
                // 计算耗时
                let end = window.performance.now();
                this.takeTime = ((end - start) / 1000).toFixed(3) + '秒';

                let data = res.resultList || [];

                // 根据产品代码 匹配产品名称
                data.forEach(ele => {
                    ele.requestId = res.requestId;
                    // 风险类型
                    ele.entryType2 = this.entryType[ele.entryType];
                    // 比较方向
                    ele.compareType2 = this.compareDirection[ele.compareType];

                    for (let i = 0; i < this.fundCodeSelectData.length; i++) {
                        const item = this.fundCodeSelectData[i];
                        if (ele.fundCode === item.fundCode) {
                            ele.fundNameSt = item.fundNameSt;
                        }
                    }
                    ele.stockNameSt = this.planDataPojo[ele.stockCode].stockNameSt;
                });

                this.$set(this, 'riskResultSourceList', data);
                this.handelThresholdTypeFilter();
            });
    }

    getAccountDebarValue(val: any) {
        this.riskOrderForm.fundCodes = val;
        console.log(this.fundAccountCode, 'fundAccountCode');
        this.$nextTick(() => {
            this.fundAccountCode = this.fundAccountCode.filter(key => {
                let index = this.fundAccountCodeSelectData.findIndex(item => item.fundAccountCode == key);
                return index > -1;
            });
        });
    }

    // 产品下拉多选返回值
    private customSelectReturn(data): void {
        this.riskOrderForm.fundCodes = data;
    }
}
</script>
<style lang="scss" scoped>
@import '@/pages/risk-measure/style/measure';
/deep/ .el-select__tags {
    flex-wrap: nowrap;
}

/deep/ span.el-tag.el-tag--info.el-tag--mini.el-tag--light {
    display: flex;
    align-items: center;
    .el-select__tags-text {
        display: inline-block;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.risk-instruction-pledge-input-main {
    height: 100px;
    line-height: 20px;
    white-space: normal;
    max-height: 100%;
    min-height: 100%;
    overflow-y: auto;
    border: 1px solid rgb(202, 202, 202);
    margin-bottom: 4px;
    border-radius: 4px;
}
.risk-instruction-pledge-input-main::-webkit-scrollbar {
    width: 0px;
    height: 0px;
}

.risk-instruction-pledge-input-main:empty:before {
    content: '请输入债券代码';
    color: #d2d2d2;
}

.risk-instruction-pledge-input-main:focus:before {
    content: none;
}
#under-net-order {
    width: 100%;
    height: 100vh;

    .middle {
        height: 1vh;
        .el-divider--horizontal {
            margin: 0 !important;
            // padding: 0 10px !important;
        }
    }
    .bottom-row {
        height: 39vh;
    }

    .top-row {
        height: 60vh;
    }

    .title {
        color: #575757;
        margin-right: 10px;
    }
    .row-height {
        // height: 50%;
        // min-height: 450px;
        .col-box {
            // height: 100%;
            padding: 10px 5px;
            .el-divider {
                margin: 0;
                margin-top: 5px;
            }
            .form-row {
                margin-top: 3px;
                .el-form-item--small {
                    margin: 0;
                    & /deep/ .el-form-item__label {
                        color: #575757;
                    }
                    & /deep/ .el-input__inner {
                        height: 28px;
                        line-height: 28px;
                    }
                }
            }
        }
        .security-box {
            .form-row {
                .el-form-item--small {
                    & /deep/ .el-input__inner {
                        background: #fff;
                        color: #575757;
                    }
                }
            }
        }
        /deep/ .el-input__inner {
            height: 28px;
            line-height: 28px;
        }
    }
    /deep/ .el-dialog__body {
        max-height: 70vh !important;
        .trant-but {
            height: 50%;
        }
    }
    .el-col-2 {
        display: flex;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        height: 400px;
        .el-button {
            margin-bottom: 5px;
        }
    }
}
</style>
